
package com.smartboot.plus.exception;


import com.smartboot.plus.api.IResultCode;
import com.smartboot.plus.api.ResultCode;


/**
 * 业务异常
 *

 */
public class ServiceException extends RuntimeException {
	private static final long serialVersionUID = 2359767895161832954L;

	private final IResultCode resultCode;

	public ServiceException(String message) {
		super(message);
		this.resultCode = ResultCode.FAILURE;
	}

	public ServiceException(IResultCode resultCode) {
		super(resultCode.getMessage());
		this.resultCode = resultCode;
	}

	public ServiceException(IResultCode resultCode, Throwable cause) {
		super(cause);
		this.resultCode = resultCode;
	}


	/**
	 * 获取 resultCode
	 *
	 * @return IResultCode
	 */
	public IResultCode getResultCode() {
		return resultCode;
	}

	/**
	 * 提高性能
	 *
	 * @return Throwable
	 */
	@Override
	public Throwable fillInStackTrace() {
		return this;
	}
	/**
	 * 重写 toString，只返回错误信息，不显示类名
	 *
	 * @return 错误消息
	 */
	@Override
	public String toString() {
		return getMessage();
	}
}

